package backstage.sys.filter;

import java.util.Map;

import backstage.staff.action.StaffAction;
import backstage.staff.pojo.Staff;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {

	public String intercept(ActionInvocation invoker) throws Exception {
		Object action = invoker.getAction();
        if (action instanceof StaffAction) {
        	//System.out.println("exit check login, because this is login action.");
            return invoker.invoke();
        }
        Map session = invoker.getInvocationContext().getSession();
        Staff staff = (Staff) session.get("staff");
        if(null != staff){
        	return invoker.invoke();
        }else{
        	return Action.LOGIN;
        }
	}

}
